package com.taxi.driver.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.taxi.driver.R;

/**
 * 类似这样的View：
 * <p/>
 * ------ xxx ------
 */
public class TagDividerView extends LinearLayout {

    private static final int[] mAttr = {android.R.attr.text};

    TextView tv;

    public TagDividerView(Context context, AttributeSet attrs) {
        super(context, attrs);
        TypedArray ta = context.obtainStyledAttributes(attrs, mAttr);
        String text = ta.getString(0);
        ta.recycle();
        initView(context, text);
    }

    private void initView(Context context, String text) {
        View mView = LayoutInflater.from(context).inflate(R.layout.layout_tagdivider, this);
        tv = (TextView) mView.findViewById(R.id.tv);
        tv.setText(text);
    }

    public void setText(int resId) {
        tv.setText(resId);
    }

    public void setText(String tag) {
        tv.setText(tag);
    }

}